import {
	getCaseList
} from '../../../../../api/weddingMan/index'
const app = getApp()
Page({
	data: {
		caseList: [],
		name: '',
		caseLen: 0,
		userId: '',
		phone: ''
	},
	onLoad: function(options) {
		this.setData({
			name: options.name,
			userId: options.userId,
			phone: options.phone
		})
		wx.setNavigationBarTitle({
			title: `${this.data.name}的作品列表`
		})
		getCaseList(this.data.userId).then((res) => {
			;
			this.setData({
				caseList: res.data.list,
				caseLen: res.data.list.length
			})
		}).catch((err) => {
			;
		})
	},
	onShow: function() {
		if (app.globalData.needRefreshCaseList === '1') {
			getCaseList(this.data.userId).then((res) => {
				;
				this.setData({
					caseList: res.data.list,
					caseLen: res.data.list.length
				});
				app.globalData.needRefreshCaseList = '0'
			}).catch((err) => {
				;
			})
		}
	},
	onUnload: function() {},
	toCaseDetail(e) {
		;
		wx.navigateTo({
			url:  '/pages/weddingMan/personal/cases/caseDetail/caseDetail?caseId=' + e.currentTarget.dataset.caseid +
				'&userId=' + this.data.userId + '&phone=' + this.data.phone + '&name=' +
				this.data.name
		});
	}
});
